/**
rid: 118739
user: 04172604ZDY
time: 2017-11-26 15:59:34
result: Runtime Error 
*/
//怀疑STL使用有问题,改用new分配内存可能的大内存占用
#include <iostream>
#include <iomanip>
//#include <vector>
using namespace std;

float T[121][121];
short aims[10000];
int aimCount;
float **data = NULL;
float result;

float deal(short self, int hasAimCount) {
    if(data[self][hasAimCount-1] != -1)
        return data[self][hasAimCount-1];
    short aim = aims[aimCount-hasAimCount];
    data[self][hasAimCount-1] = T[self][aim];
    if(hasAimCount > 1) {
        float orig = deal(self, hasAimCount - 1);
        float replace = deal(aim, hasAimCount - 1);
        data[self][hasAimCount - 1] *= (orig > replace ? orig : replace);
    }
    if(data[self][hasAimCount-1] < result)
        return 0;
    return data[self][hasAimCount-1];
}

int main() {
    int n;
    while(cin >> n) {
        int R = n*(n-1)*(n-2)/6;//max 120
        //init T
        for(int i = 0; i < R; i++) {
            for(int j = 0; j < R; j++) {
                cin >> T[i][j];
            }
        }
        //init aims
        cin >> aimCount;
        for(int i = 0; i < aimCount; i++) {
            cin >> aims[i];
        }
        //init data
        data = new float*[R];
        for(int i = 0; i < R; i++) {
            data[i] = new float[aimCount];
            for(int j = 0; j < aimCount; j++)
                data[i][j] = -1;
        }
        //deal with data
        result = 0;
        for(int i = 0; i < R; i++) {
            float cache = deal(i, aimCount);
            if(cache > result)
                result = cache;
        }
        //delete data
        for(int i = 0; i < R; i++) {
            delete[] data[i];
        }
        delete[] data;
        //output
        cout << std::fixed << setprecision(6) << result << endl;
    }
    return 0;
}